package v2.chapter9.jaas3;

import java.io.File;
import java.security.PrivilegedAction;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

public class MyPrivilegedAction implements PrivilegedAction {

	@Override
	public Object run() {
	    System.out.println("\nYour java.home property value is: " + System.getProperty("java.home"));
		System.out.println("\nYour JAVA_HOME property value is: " + System.getProperty("JAVA_HOME"));
		System.out.println("\nYour user.home property value is: " + System.getProperty("user.home"));

		Map<String, String> map = System.getenv();
		for (Iterator<String> itr = map.keySet().iterator(); itr.hasNext();) {
			String key = itr.next();
			System.out.println(key + "=" + map.get(key));
		}

		File f = new File("foo.txt");
		System.out.print("\nfoo.txt does ");
		if (!f.exists())
			System.out.print("not ");
		System.out.println("exist in the current working directory.");
		return null;
	}

}
